home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
prolog_2.zip
/
PUZZLES.ZIP
/
BENCH.PRO
< prev
next >
Wrap
Text File
|
1986-07-20
|
640b
|
20 lines
/*
Concatentate strings, using append. If the below is asked,
?-append( "ABC", "DEF", X ), append( "123", X, Y ), append( Y, "XYZ", Z ),
printstring( Z ).
you will get: Z = "123ABCDEFXYX", printed out as a list of ASCII codes. */
append( [], L, L ).
append( [Z|L1], L2, [Z|L3] ) :- append( L1, L2, L3 ).
printstring( [] ).
printstring( [H|T] ) :- put( H ), printstring( T ).
lips(L) :- rev( [1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30], L ).
rev( [], [] ).
rev( [H|T], L ) :- rev( T,Z), append( Z, [H], L ).